<?php
	/**
	 * 获取回放数据
	 */
    class ReplayCombatGain extends APIBase {
		
		public $tag = "ReplayCombatGain";
    	public $isLogin = false;
		
		public function before() {
			$this->initCacheRedis();
			$this->initMysql();
			return true;
		}
		public function logic() {
			//$ann = $this->cache_redis->hMGet("ha:*", array("id","title","content","image_url"));
			//$combatgains= $this->cache_redis->keys("hCombatGains:*");
			$replaycode =  $this->param['replaycode'];
			$result = $this->cache_redis->hGetAll("hUserReplaydata:$replaycode");
			if(!empty($result)){
				  $this->returnData($result);		
			}else{
				$sql = "select replay,time,gameID,replayCode from customroomreplay where replayCode = '$replaycode'";
			    $result = $this->mysql->query($sql);
				$list = array();
				$rows = array();
				if ($result) {
		            $row = mysql_fetch_assoc($result);
					if($row){
						$replaycode = (string)$row['replayCode'];
		                $r['gameID'] = (int)$row['gameID'];
		                $r['replay'] = (string)$row['replay'];
		                $r['time'] = (int)$row['time'];
		                $this->cache_redis->hMset("hUserReplaydata:$replaycode",$r);
				        $this->returnData($r);
					}else{
					    $this->returnError(301,"对不起，暂无回放数据！");
				    }	
	            }
			}

		}
		
        public function after() {
			$this->deinitCacheRedis();
		}
    }
?>
